<template>
  <div class="custom-image-body">
    <el-upload
      class="avatar-uploader"
      action="/rest/api/upload/editor"
      :show-file-list="false"
      :on-success="handleSuccess"
    >
      <slot name="reference" />
    </el-upload>
  </div>
</template>

<script>
export default {
  name: 'CustomImageUpload',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    fallBackFunction: {
      type: String,
      require: true
    }
  },
  methods: {
    handleSuccess(response, file, fileList) {
      this.$emit('change', file.response.url)
    }
  }
}
</script>

<style scoped>
.custom-image-body {
  width: 100%;
  height: 80px;
}
.avatar-uploader {
  width: 80px;
  height: 80px;
  line-height: 80px;
  text-align: center;
  border: 1px #909399 dashed;
  border-radius: 4px;
  background-color: #F2F6FC;
}
</style>
